#include "TrackDataBase.h"

void CTrackDataBase::LoadTracks( char* TracksFileName )
{
	FILE* pFile = fopen(TracksFileName, "r");
	VISIO_ASSERT(pFile);
	fscanf(pFile, "%d", &m_NumTracks);
	for (UINT i = 0; i < m_NumTracks; i++)
	{
		UINT NumViews = 0;
		ViewVector newViews;
		fscanf(pFile, "%d", &NumViews);
		for (UINT j = 0; j < NumViews; j++)
		{
			UINT ImageIndex, KeyIndex;
			fscanf(pFile, "%d %d", &ImageIndex, &KeyIndex);
			View newView(ImageIndex, KeyIndex);
			newViews.push_back(newView);
		}
		CTrackData newTrack(newViews);

		m_TrackData.push_back(newTrack);
	}
	fclose(pFile);
}

UINT CTrackDataBase::GetNumOfTracks() const
{
	VISIO_ASSERT(m_NumTracks == m_TrackData.size())
	return m_NumTracks;
}

CTrackData* CTrackDataBase::GetTrack( UINT index )
{
	return &m_TrackData[index];
}